$(function() {
    //地区
    function ProLevel() {
        let Provincial_Level = Interceptor('/getProvincial', 'post');
        $('.region_remen').html('');
        for (i = 0; i <= Provincial_Level.data.length - 1; i++) {
            const ProLevelTitle = `
                        <a onclick="PageRegion_A($(this).text())">${Provincial_Level.data[i].cri_name}</a>
                    `
            $('.region_remen').append(ProLevelTitle);
        }
    }

    PageRegion_A = function(SeaPagReg) {
        $('.nav_center_add_con > span').text(SeaPagReg);
        $('.nav_center_add_con > span').attr("title", SeaPagReg);
        $('#region').css('display', 'none');
    };

    $('.nav_center_add_con').click(function() {
        $('#region').show();
        $('#region_div').show();
        ProLevel();
        if ($('#region').show()) {
            $('#region_div').click(function() {
                $('#region').css('display', 'none');
            });
        };
    });

    //职业类型
    $('.nav_centon_type').mouseover(function() {
        $('.nav_centon_type_ul').show();
        $('.nav_centon_type_ul').mouseenter(function() {
            $('.nav_centon_type_ul').show();
            $('.nav_centon_type_ul > li').click(function() {
                let NavCentonType = $(this).text();
                $('.nav_center_type_con_span').text(NavCentonType);
            });
        });
    }).mouseleave(function() {
        $('.nav_centon_type_ul').hide();
    });

    //搜索
    $('.nav_centon_button').click(function() {
        let SearchText = $('#nav_search').val();
        if (SearchText.length != 0) {
            let Searchtext = "SearchPage.html?SearchText=" + SearchText;
            $('#nav_button').attr('href', Searchtext);
        } else {
            let Searchtext = "SearchPage.html";
            $('#nav_button').attr('href', Searchtext);
        }
    });

    let identity = sessionStorage.getItem('identity');
    let postion = sessionStorage.getItem('postion');
    if (identity == 0) {
        headpor();
    } else if (identity == 1) {
        headpor();
    } else if (identity == 2) {
        User_Company();
    };
    if (postion == 0) {
        headpor();
    } else if (postion == 1) {
        headpor();
    } else if (postion == 2) {
        User_Company();
    };

    //个人中心头像
    function headpor() {
        let headportrait = Interceptor('/userHeader', 'post');
        const headportraitTetle = `
            <img src="${headportrait.data.header}" alt="" class="nav_right_img">
            <span class="nav_right_span">个人中心</span>
        `
        $('.nav_right  > a').append(headportraitTetle);
    }

    //公司中心
    function User_Company() {
        let UserCompany = Interceptor('/userCompany', 'post');
        const UserCompany_TetleStr = `
            <a href="CompanyIntroduce.html?company_id=${UserCompany.data[0].company_id}">
                <img src="${UserCompany.data[0].header}" alt="" class="nav_right_img">
                <span class="nav_right_span">公司中心</span>
            </a>
        `
        $('.nav_right').html(UserCompany_TetleStr);
    }
});